package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.*;

/**
 * @author Artem Kalchenko
 * 
 */
public class SystemTest {

	private static Bank theBank = new Bank();
	private static BankService bs = new BankService();

	public static void main(String[] args) {
		Client clSmith = new Client("Smith", Gender.MALE);
		Client clLiskov = new Client("Liskov", Gender.FEMALE,
				new CheckingAccount(500, 100));
		Client clSmithCopy;
		
		clSmith = bs.addClient(theBank, clSmith);
		clLiskov = bs.addClient(theBank, clLiskov);
		
		System.out.println("List of clients:\n"
				+ bs.getClientsListAsString(theBank));
		System.out.println(bs.getAccountsListAsString(theBank));

		// add same client again
		clSmithCopy = bs.addClient(theBank, "Smith", Gender.MALE);
		
		// add an account for Smith
		bs.addAccount(clSmith, new SavingsAccount(750));
		System.out.println(bs.getAccountsListAsString(theBank));

		// deposit money on Smith's acc
		bs.deposit(bs.getClientsList(theBank).get(0), 249);
		System.out.println(bs.getClientAccount(bs.getClientsList(theBank).get(0)));

		// withdraw negative amount
		bs.withdraw(clLiskov, -100);
		// withdraw too much money from Liskov
		bs.withdraw(clLiskov, 666);

		// set new overdraft for Liskov
		bs.setOverdraftLimit(clLiskov, 250);

		bs.withdraw(clLiskov, 666);

		System.out.println(bs.getAccountsListAsString(theBank));
		
		bs.deposit(clLiskov, 666);
		System.out.println(bs.getAccountsListAsString(theBank));
		
		// check how equals() works
		clSmithCopy = new Client("Smith", Gender.MALE);
		System.out.println(clSmith.equals(clSmithCopy));
		System.out.println(clSmith == clSmithCopy);
		
		bs.deposit(clSmith, 3.1415926);
		System.out.println(clSmith.getAccount().decimalValue() + " == [" + clSmith.getAccount().getBalance() + "]");
	}
}
